#pragma once

#include <memory>
#include <string>
#include <functional>
#include "rocksdb/status.h"

namespace rocksdb {
	class DB;
	class ColumnFamilyHandle;
}

namespace helper {
namespace rocksdb {

class Options;

class Table {
public:
    using Slice = ::rocksdb::Slice;
    using Status = ::rocksdb::Status;
	Table(std::shared_ptr<::rocksdb::DB> db, const std::string & name, ::rocksdb::ColumnFamilyHandle * handle, const Options & options);
	~Table();

	Status put(const Slice & key, const Slice & value);
	Status get(const Slice & key, std::string & value) ;
	Status del(const Slice & key);

	Status put(const int64_t key, const Slice & value);
	Status get(const int64_t key, std::string & value) ;
	Status del(const int64_t key);

	Status put(const uint64_t key, const Slice & value);
	Status get(const uint64_t key, std::string & value) ;
	Status del(const uint64_t key);


    using Visitor = std::function<bool(const Slice & key, const Slice& value)>;
    bool foreach(const Visitor & v, const Slice & start = Slice(), const Slice & end = Slice()) const;

private:
	std::shared_ptr<::rocksdb::DB> _db;
	std::string _name;
	::rocksdb::ColumnFamilyHandle * _handle;

    const Options & _options;
};

}//end namespace rocksdb
}//end namespace helper
